//
// Created by zhanghj on 2023/3/24.
//

#ifndef RELEASEMUSIC_LOG_H
#define RELEASEMUSIC_LOG_H

#include <libavutil/log.h>
#include <android/log.h>
#define LOG_TAG "C.out"
#define AV_LOG_level AV_LOG_WARNING

#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
#define LOGF(...) __android_log_print(ANDROID_LOG_FATAL, LOG_TAG, __VA_ARGS__)

void androidlog(void* ptr, int level, const char* fmt,va_list vl){

/*	if(fp){
		vfprintf(fp,fmt,vl);
	}*/
/*	LOGI("The Level is: %d,%d,%d,%d,%d \n",AV_LOG_DEBUG,AV_LOG_INFO,AV_LOG_WARNING,AV_LOG_ERROR,AV_LOG_FATAL);*/
//	LOGI("local level is:%d ,The Level is:%d \n",av_log_get_level(),level);
if(level>av_log_get_level()) return;
	switch(level){
	case AV_LOG_DEBUG:
        LOGD(fmt,vl);
    	break;
    case AV_LOG_INFO:
        LOGI(fmt,vl);
        break;
    case AV_LOG_WARNING:
        LOGW(fmt,vl);
        break;
    case AV_LOG_ERROR:
        LOGE(fmt,vl);
        break;
    case AV_LOG_FATAL:
        LOGF(fmt,vl);
        break;
	}
}

void log_init(){
    av_log_set_callback(androidlog);
    av_log_set_level(AV_LOG_level);

}

#endif //RELEASEMUSIC_LOG_H
